/**************************************************************************************************
* Title: SumObjectAlignedBox.cpp
* Author: Gael Huber
* Description: An object aligned bounding box
**************************************************************************************************/
#include "SumObjectAlignedBox.h"

/**************************************************************************************************
* Default constructor
**************************************************************************************************/
ObjectAlignedBox::ObjectAlignedBox(void)
{ }

/**************************************************************************************************
* Constructor with default parameters
**************************************************************************************************/
ObjectAlignedBox::ObjectAlignedBox(const Vector3_16f& p, const Vector3_16f& d, 
	const Vector3_16f& x, const Vector3_16f& y, const Vector3_16f& z)
	: _position(p), _dimensions(d)
{ 
	_orientation[0] = x;
	_orientation[1] = y;
	_orientation[2] = z;
}

/**************************************************************************************************
* Copy constructor
**************************************************************************************************/
ObjectAlignedBox::ObjectAlignedBox(const ObjectAlignedBox& rhs)
	: _position(rhs.position()), _dimensions(rhs.dimensions())
{
	_orientation[0] = rhs.orientation()[0];
	_orientation[1] = rhs.orientation()[1];
	_orientation[2] = rhs.orientation()[2];
}

/**************************************************************************************************
* Destructor
**************************************************************************************************/
ObjectAlignedBox::~ObjectAlignedBox(void)
{ }

/**************************************************************************************************
* Assignment operator
**************************************************************************************************/
ObjectAlignedBox& ObjectAlignedBox::operator=(const ObjectAlignedBox& rhs) {
	// Self-assignment guard
	if(this == &rhs)
		return *this;

	// Assign and return
	_position = rhs.position();
	_dimensions = rhs.dimensions();
	_orientation[0] = rhs.orientation()[0];
	_orientation[1] = rhs.orientation()[1];
	_orientation[2] = rhs.orientation()[2];
	return *this;
}

/**************************************************************************************************
* Equivalence operator
**************************************************************************************************/
bool ObjectAlignedBox::operator==(const ObjectAlignedBox& rhs) {
	return _position == rhs.position() && _dimensions == rhs.dimensions() && _orientation[0] == rhs.orientation()[0] &&
		_orientation[1] == rhs.orientation()[1] && _orientation[2] == rhs.orientation()[2];
}

/**************************************************************************************************
* Non-equivalence operator
**************************************************************************************************/
bool ObjectAlignedBox::operator!=(const ObjectAlignedBox& rhs) {
	return _position != rhs.position() || _dimensions != rhs.dimensions() || _orientation[0] != rhs.orientation()[0] ||
		_orientation[1] != rhs.orientation()[1] || _orientation[2] != rhs.orientation()[2];
}

/**************************************************************************************************
* Return position
**************************************************************************************************/
Vector3_16f& ObjectAlignedBox::position(void) {
	return _position;
}

/**************************************************************************************************
* Return position
**************************************************************************************************/
const Vector3_16f& ObjectAlignedBox::position(void) const {
	return _position;
}

/**************************************************************************************************
* Return dimensions
**************************************************************************************************/
Vector3_16f& ObjectAlignedBox::dimensions(void) {
	return _dimensions;
}

/**************************************************************************************************
* Return dimensions
**************************************************************************************************/
const Vector3_16f& ObjectAlignedBox::dimensions(void) const {
	return _dimensions;
}

/**************************************************************************************************
* Return orientation
**************************************************************************************************/
Vector3_16f* ObjectAlignedBox::orientation(void) {
	return _orientation;
}

/**************************************************************************************************
* Return orientation
**************************************************************************************************/
const Vector3_16f* ObjectAlignedBox::orientation(void) const {
	return _orientation;
}